<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>IFE JavaScript Task 02</title>
    <link type="text/css" rel="stylesheet" href="../../public/css/style.css"/>
</head>
<style>
    #display{
        font-size: 18px;
    }
</style>
<body>
<div class="nav">
    <a href="http://ife.baidu.com/course/detail/id/91" target="_blank">查看习题要求</a>
    <a href="http://ife.giscafer.com">返回demo演示站</a>
</div>
<div id="code-display">
    <h3>污染城市列表</h3>
    <ul id="aqi-list">
        <!--
            <li>第一名：福州（样例），10</li>
              <li>第二名：福州（样例），10</li> -->
    </ul>

    <script type="text/javascript">

        var aqiData = [
            ["北京", 90],
            ["上海", 50],
            ["福州", 10],
            ["广州", 50],
            ["成都", 90],
            ["西安", 100]
        ];

        (function () {

            /*
             在注释下方编写代码
             遍历读取aqiData中各个城市的数据
             将空气质量指数大于60的城市显示到aqi-list的列表中
             */
            var liHtmlStr="";
            var count=1;
            for(var i=0;i<aqiData.length;i++){
                if(aqiData[i][1]>60){
                    liHtmlStr+='<li>第'+convert(count)+'名：'+aqiData[i][0]+'，'+aqiData[i][1]+'</li>';
                    count++;
                }
            }
            document.getElementById("aqi-list").innerHTML=liHtmlStr;


            function convert(n){
                var arr=["零","一","二","三","四","五","六","七","八","九","十"];
                return arr[n];
            }
        })();

    </script>

</div>

<div id="code-source">
    <h2>JavaScript源码</h2>
    <pre>
         (function () {

            /*
             在注释下方编写代码
             遍历读取aqiData中各个城市的数据
             将空气质量指数大于60的城市显示到aqi-list的列表中
             */
            var liHtmlStr="";
            var count=1;
            for(var i=0;i<aqiData.length;i++){
                if(aqiData[i][1]>60){
                    liHtmlStr+='&lt;li&gt;第'+convert(count)+'名：'+aqiData[i][0]+'，'+aqiData[i][1]+'&lt;/li&gt;';
                    count++;
                }
            }
            document.getElementById("aqi-list").innerHTML=liHtmlStr;


            function convert(n){
                var arr=["零","一","二","三","四","五","六","七","八","九","十"];
                return arr[n];
            }
        })();
    </pre>
</div>
</body>
</html>